package com.qf.team2.netdisc.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * swagger2配置
 *
 * @author Simon_Wong
 * @date 2021/05/26 11:24
 */
@EnableSwagger2
@Configuration
@ComponentScan("com.qf.team2.netdisc.controller")
@SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
public class Swagger2Config {
    @Bean
    public Docket createAPI() {
        return new Docket(DocumentationType.SWAGGER_2)
                .forCodeGeneration(true)
                .select()
                .apis(RequestHandlerSelectors.any())
                //过滤生成链接
                .paths(PathSelectors.any())
                .build()
                .apiInfo(apiInfo());
    }

    private ApiInfo apiInfo() {
        //name:作者  url:来源     email：联系方式
        Contact contact = new Contact("jerry", "http://baidu.com"
                , "jerry@163.com");
        return new ApiInfoBuilder()
                //开放文档
                .license("Apache License Version 2.0")
                //用途
                .title("暴富云分享功能")
                //详细描述
                .description("分享功能前端专用分享")
                //作者
                .contact(contact)
                //版本号
                .version("1.0")
                .build();
    }
}
